#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
	srand(time(NULL));
	int m, n, i, j, num, c;
	scanf("%d%d", &n, &m);
	int realOffset = m % n;

	int *a = malloc(sizeof(int)*n);
	for (i = 0; i < n; i++) a[i] = rand();
	for (i = 0; i < n; i++) printf("%d\t", a[i]);
	printf("\n");

	for (i = 0; i < realOffset; i++) {
		num = a[n - 1];
		for (j = 0; j < n; j++) {
			c = num;
			num = a[j];
			a[j] = c;
		}
	}

	for (i = 0; i < n; i++) printf("%d\t", a[i]);
	printf("\n");
	free(a);
	return 0;
}